home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2609 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: atglab.bls.com!Alun.Champion
  2. From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: *Pointer to Functions();   /* HELP */
  5. Date: 22 Jan 1996 16:31:44 GMT
  6. Organization: Computer People Inc.
  7. Message-ID: <ALUN.CHAMPION.96Jan22113144@g7240065.bridge.bst.bls.com>
  8. References: <4dvrq8$c2c@news.unicomp.net>
  9. NNTP-Posting-Host: bstfirewall.bst.bls.com
  10. In-reply-to: jgore@conline.com's message of 22 Jan 1996 11:18:32 GMT
  11.  
  12. In article <4dvrq8$c2c@news.unicomp.net> jgore@conline.com (Jerry_Gore) writes:
  13.  
  14.    How do I pass a pointer to a funtion?
  15. ; The following is found in a program:
  16.  
  17. ;     #define WORD    unsigned int       
  18. ;     void    InstallTimer0(WORD period,void far (*func)(void));
  19.  
  20. ; My function is thus:
  21.  
  22. ;     void far animate(void)    /* I added 'far' for no good reason.   */
  23. ;     {                         /* It uses that name in InstallTimer0. */ 
  24. ;     /* do what ever */        
  25. ;     return;
  26. ;     }
  27.  
  28. ; How do I send InstallTimer0 the pointer to my function animate ???
  29. ; I tried:
  30.  
  31.     InstallTimer0(120 , (*animate)());
  32.  
  33. ; But of course, this does not work and neither did anything else!
  34. ; What do I do ???
  35.  
  36. Try:
  37.     InstallTimer0(120 , animate);
  38.  
  39. The identifier for the function is the pointer to that function (or can be
  40. resolved to the pointer to that function).
  41.  
  42. NB: Make sure a declaration of the animate() function happens before
  43. the call to InstallTimer0.
  44.  
  45. Regards
  46.  
  47.    -A.
  48. -- 
  49. | A.Champion                |
  50.